package com.chenyaoze.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket getDocker()
    {

        //创建封面的信息对象
        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        apiInfoBuilder.title("接口说明")
                .description("详情介绍随便写写")
                .version("2.0.1")
                .contact(new Contact("ck","www.baidu.com","553490664@qq.com"));//作者信息
        ApiInfo build = apiInfoBuilder.build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(build)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.chenyaoze.controller"))//扫描包
                .paths(PathSelectors.any())//可以指定开头路径的接口生产文档 "/user"
                .build();
        return docket;

    }

}
